<template>
  <div ><!--v-for="(order,index) in orderList"-->
    <van-sticky style="background-color: white">
      <van-nav-bar
        title="全部订单"
        left-text="返回"
        left-arrow
        @click-left="onClickLeft"
      />
    </van-sticky>




    <div v-for="(item,index) in orderList">

      <van-card
        :num="item.num"
        :price="item.amount/100"
        :tag="stateFormat(item.status)"
        :desc="item.orderTime"
        :title="item.consignee"
        thumb="https://unpkg.com/@vant/assets/ipad.jpeg"
        @click="jump('/orderDetail/'+item.id)"
      >
        <div ></div>

        <template #footer>
          <van-button size="mini">确认收获</van-button>
          <van-button size="mini">取消订单</van-button>
        </template>
      </van-card>
    </div>
    <div v-if="orderList.length==0"><van-empty description="暂无订单" /></div>




  </div>

</template>

<script>



export default {
  name: "order.vue",
  created(){
    this.loadData()
  },
  setup() {
    const onClickLeft = () => history.back();
    return {
      onClickLeft,
    };
  },
  data(){
    return{
      loading:true,
      orderList: [],
    }
  },

  methods:{
    jump(path){
      this.$router.push(path)

    },
    loadData() {
      let _this = this
      this.$axios.post("/order/selectOrderOfUser3").then(
        function (response) {
          console.log(response)
          console.log("订单", _this.tableData = response.data.data.orderList)
          _this.orderList = response.data.data.orderList

        }
      )
    }
    ,
    stateFormat(row) {
      console.log("获取的状态序号是"+row);
      let state = row;
      if (state === 1) {
        return "待付款";
      } else if (state === 2) {
        return "待派送";
      } else if (state === 3) {
        return "待收货";
      } else if (state === 4) {
        return "已派送";
      } else if (state === 5) {
        return "已取消";
      }
    },
  }
}
</script>

<style scoped>

</style>
